{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import chardet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "file = \"新建文本文档.txt\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(file, 'rb') as f:\n",
    "    s = f.read()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "d = chardet.detect(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'encoding': 'utf-8', 'confidence': 0.99, 'language': ''}\n"
     ]
    }
   ],
   "source": [
    "print(d)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "e = d['encoding']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'utf-8'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 使用GB18030获得最大的兼容性，GB2312、GBK"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if e.lower().startswith('gb'):\n",
    "    e = 'gb18030'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(file, encoding = e) as f:\n",
    "    s = f.readlines()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "咨询公司\n",
      "\n",
      "双碳目标\n",
      "\n",
      "打造高地的行动计划\n",
      "\n",
      "\t分管新能源电力\n",
      "\n",
      "\t双脱钩，能源发展和碳脱钩：不让上气电\n",
      "\n",
      "\n",
      "\n",
      "双碳目标提出\n",
      "\n",
      "\t香饽饽的经济性\n",
      "\n",
      "\t解决外送问题\n",
      "\n",
      "\n",
      "\n",
      "十四五：6000w，新能源4000w\n",
      "\n",
      "\t总装机8400w，新能源6000w\n",
      "\n",
      "\n",
      "\n",
      "总书记高地\n",
      "\n",
      "\t1亿，8000w\n",
      "\n",
      "\n",
      "\n",
      "碳脱钩，碳达峰\n",
      "\n",
      "\t加码\n",
      "\n",
      "\t\n",
      "\n",
      "※进展\n",
      "\n",
      "\t园区规划：16个园区\n",
      "\n",
      "\t园区的排序\n",
      "\n",
      "\t是否完全可以开发？\n",
      "\n",
      "\t平台验证。\n",
      "\n",
      "\n",
      "\n",
      "国家能源局委托青海电网\n",
      "\n",
      "\t做课题\n",
      "\n",
      "\t以新能源为主\n",
      "\n",
      "\t对电网，革命性的挑战\n",
      "\n",
      "\n",
      "\n",
      "储能先行示范区\n",
      "\n",
      "\t科技司\n",
      "\n",
      "\t储能下一步发展和支撑新能源发展\n",
      "\n",
      "\t不是验证，而是示范应用\n",
      "\n",
      "\t\n",
      "\n",
      "多能互补\n",
      "\n",
      "\t高波动性\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "服务于规划层面还是项目\n",
      "\n",
      "\n",
      "\n",
      "\t电网接入能力有限\n",
      "\n",
      "\t\n",
      "\n",
      "\t是否具备接入条件\n",
      "\n",
      "\n",
      "\n",
      "\t电网的数据量不多\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "袁局\n",
      "\n",
      "能源局在青海能源行业管理\n",
      "\n",
      "\t应该起到主导作用\n",
      "\n",
      "\t电网、正厅级（三级公司->二级公司）\n",
      "\n",
      "需要能源局对整个青海能源做规划\n",
      "\n",
      "\t指挥棒\n",
      "\n",
      "不能被动跟从电网\n",
      "\n",
      "\n",
      "\n",
      "省长，土地问题，电网亏损\n",
      "\n",
      "能源局不是电网的发展部\n",
      "\n",
      "自身能力的建设\n",
      "\n",
      "\t智囊团\n",
      "\n",
      "\t机关单位寻求智囊团\n",
      "\n",
      "\t设计院\n",
      "\n",
      "\t电规总院\n",
      "\n",
      "\t水规总院\t大院，力量配置不足\n",
      "\n",
      "\t\t更关心国家发改委，国规院\n",
      "\n",
      "\n",
      "\n",
      "强·监管\n",
      "\n",
      "\t跟得上高地的建设\n",
      "\n",
      "\n",
      "\n",
      "企业、地方看三步\n",
      "\n",
      "\t我们看五步、十步\n",
      "\n",
      "\t不光服务地方、服务企业\n",
      "\n",
      "\t调动委领导、省领导\n",
      "\n",
      "\t\t协调国家层面\n",
      "\n",
      "\t能协调电网就不错了。。。。。。\n",
      "\n",
      "人无远虑必有近忧\n",
      "\n",
      "发改委，搞计划\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "李处\n",
      "\n",
      "\t服务：规划、布局\n",
      "\n",
      "\t服务：企业\n",
      "\n",
      "\t基础电量的分析。\n",
      "\n",
      "\t比如：清yuzhiliu\n",
      "\n",
      "\t如何支撑第二条特高压线\n",
      "\n",
      "\t1亿，4条\n",
      "\n",
      "\t双脱钩\n",
      "\n",
      "\t\t脱碳、减排\n",
      "\n",
      "\t500万气电，调峰，源网荷储\n",
      "\n",
      "\t比亚迪\n",
      "\n",
      "\t\n",
      "\n",
      "\t如何对电网提要求\n",
      "\n",
      "\t\t3400->5000，如何支撑（气电不上的话）\n",
      "\n",
      "\t\t火电退出（后半段退出）\n",
      "\n",
      "\t\t该上特高压线，\n",
      "\n",
      "\t12亿，10%=1.2亿\n",
      "\n",
      "\t剩余资源量，哪些可以开发\n",
      "\n",
      "\t局领导、省领导。\n",
      "\n",
      "\t能源局的下一步布局，非常重要\n",
      "\n",
      "\t\t能用、可用的\n",
      "\n",
      "\t5月份\n",
      "\n",
      "\t\t报十四五，8000-12000万千瓦\n",
      "\n",
      "\n",
      "\n",
      "周局\n",
      "\n",
      "\n",
      "\n",
      "车主任\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for i in s:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
